//
//  FileManager.m
//  Conference
//
//  Created by Xiang He on 12-11-23.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import "FileManager.h"

@implementation FileManager
@synthesize myFile;
static FileManager* _sharedFileManager = nil;

+(FileManager*)sharedFileManager
{
	@synchronized([FileManager class])
	{
		if (!_sharedFileManager)
			[[[self alloc] init] autorelease];
        
		return _sharedFileManager;
	}
	return nil;
}



+(id)alloc
{
	@synchronized([FileManager class])
	{
		NSAssert(_sharedFileManager == nil, @"Attempted to allocate a second instance of a singleton.");
		_sharedFileManager = [super alloc];
		return _sharedFileManager;
	}
    
	return nil;
}



-(id)init
{
    if ((self = [super init]))
    {
        NSString *appSupport = [NSSearchPathForDirectoriesInDomains( NSApplicationSupportDirectory, NSUserDomainMask, YES ) objectAtIndex:0];
        NSString *dir = [NSString stringWithFormat:@"%@/iPhoneKuapay", appSupport];
        
        NSLog(@"\nDirectory: %@\n\n",dir);
        
        [[NSFileManager defaultManager] createDirectoryAtPath:dir 
                                  withIntermediateDirectories:YES 
                                                   attributes:nil
                                                        error:nil];
        
        self.myFile = [dir stringByAppendingPathComponent:@"qR.png"];
    }
    return self;
}



-(void)dealloc
{ 
    [myFile release];
    [super dealloc];
    
    
    _sharedFileManager = nil;
    
}

@end
